package ustc.xiaoyang.mapper;

import org.apache.ibatis.annotations.*;
import ustc.xiaoyang.pojo.Clazz;
import ustc.xiaoyang.pojo.dto.ClazzPageQueryDTO;

import java.util.List;

@Mapper
public interface ClazzMapper {


    /**
     * 分页查询班级
     * @param clazzPageQueryDTO
     * @return
     */
    List<Clazz> pageList(ClazzPageQueryDTO clazzPageQueryDTO);

    /**
     * 添加班级
     * @param clazz
     */
    @Insert("insert into clazz(name, room, begin_date, end_date, master_id, subject, create_time, update_time) value(#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void add(Clazz clazz);
    /**
     * 根据id查询班级
     * @param id
     * @return
     */
    @Select("select * from clazz where id = #{id}")
    Clazz getById(Integer id);

    /**
     * 修改班级
     * @param clazz
     */
    @Update("update clazz set name = #{name}, room = #{room}, begin_date = #{beginDate}, end_date = #{endDate}, master_id = #{masterId}, subject = #{subject}, update_time = #{updateTime} where id = #{id}")
    void update(Clazz clazz);

    /**
     * 删除班级
     * @param id
     */
    @Delete("delete from clazz where id = #{id}")
    void deleteById(Integer id);

    /**
     * 查询所有班级
     * @return
     */
    @Select("select * from clazz")
    List<Clazz> list();
}
